Fill in the gif's blank areas for interlacing and progressive loading.
authorJonathan Blandford <jrb@redhat.com>
Wed, 3 Nov 1999 00:20:27 +0000 (00:20 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Wed, 3 Nov 1999 00:20:27 +0000 (00:20 +0000)
1999-11-02  Jonathan Blandford  <jrb@redhat.com>

* src/io-gif.c (gif_fill_in_lines): Fill in the gif's blank areas
for interlacing and progressive loading.

gdk-pixbuf/ChangeLog
gdk-pixbuf/io-gif.c

index d7fb974a7b452fc1f210b6dadc65fb32623a84a3..3091185caefec710d8022027c34aada94e7ab714 100644 (file)
@@ -1,3 +1,8 @@
+1999-11-02  Jonathan Blandford  <jrb@redhat.com>
+
+       * src/io-gif.c (gif_fill_in_lines): Fill in the gif's blank areas
+       for interlacing and progressive loading.
+
 1999-11-02  Cody Russell  <bratsche@dfw.net>
        * src/gdk-pixbuf-drawable.c (gdk_pixbuf_from_drawable_core): Now
        calls gdk_pixbuf_new_from_art_pixbuf() instead of gdk_pixbuf_new().
index cd2221a1b87873221dc97a622d4552df7836d43e..d998a4e05d8050906e6b3b62929f90c9a2bb88e4 100644 (file)
@@ -155,7 +155,10 @@ static int count = 0;
 static int
 ReadOK (GifContext *context, guchar *buffer, size_t len)
 {
-       gint retval, i;
+       gint retval;
+#ifdef IO_GIFDEBUG
+       gint i;
+#endif
        if (context->file) {
                count += len;
 #ifdef IO_GIFDEBUG
@@ -519,7 +522,8 @@ lwz_read_byte (GifContext *context)
                        int count;
                        unsigned char buf[260];
 
-                       g_error (" DID WE EVER EVER GET HERE\n");
+                       /*g_error (" DID WE EVER EVER GET HERE\n");*/
+                       g_warning ("unhandled case.  This won't load correctly\n");
                        
                        if (ZeroDataBlock)
                                return -2;
@@ -580,6 +584,56 @@ gif_set_get_lzw (GifContext *context)
        context->draw_pass = 0;
 }
 
+static void
+gif_fill_in_pixels (GifContext *context, guchar *dest, gint offset, guchar v)
+{
+       guchar *pixel = NULL;
+
+       if (context->gif89.transparent) {
+               pixel = dest + (context->draw_ypos + offset) * gdk_pixbuf_get_rowstride (context->pixbuf) + context->draw_xpos * 4;
+               *pixel = context->color_map [0][(guchar) v];
+               *(pixel+1) = context->color_map [1][(guchar) v];
+               *(pixel+2) = context->color_map [2][(guchar) v];
+               *(pixel+3) = (guchar) ((v == context->gif89.transparent) ? 0 : 65535);
+       } else {
+               pixel = dest + (context->draw_ypos + offset) * gdk_pixbuf_get_rowstride (context->pixbuf) + context->draw_xpos * 3;
+               *pixel = context->color_map [0][(guchar) v];
+               *(pixel+1) = context->color_map [1][(guchar) v];
+               *(pixel+2) = context->color_map [2][(guchar) v];
+       }
+}
+
+
+/* only called if progressive and interlaced */
+static void
+gif_fill_in_lines (GifContext *context, guchar *dest, guchar v)
+{
+       switch (context->draw_pass) {
+       case 0:
+               if (context->draw_ypos > 4) {
+                       gif_fill_in_pixels (context, dest, -4, v);
+                       gif_fill_in_pixels (context, dest, -3, v);
+               }
+               if (context->draw_ypos < (context->frame_height - 4)) {
+                       gif_fill_in_pixels (context, dest, 3, v);
+                       gif_fill_in_pixels (context, dest, 4, v);
+               }
+       case 1:
+               if (context->draw_ypos > 2)
+                       gif_fill_in_pixels (context, dest, -2, v);
+               if (context->draw_ypos < (context->frame_height - 2))
+                       gif_fill_in_pixels (context, dest, 2, v);
+       case 2:
+               if (context->draw_ypos > 1)
+                       gif_fill_in_pixels (context, dest, -1, v);
+               if (context->draw_ypos < (context->frame_height - 1))
+                       gif_fill_in_pixels (context, dest, 1, v);
+       case 3:
+       default:
+               break;
+       }
+}
+
 static int
 gif_get_lzw (GifContext *context)
 {
@@ -619,6 +673,9 @@ gif_get_lzw (GifContext *context)
                        *(temp+2) = context->color_map [2][(guchar) v];
                }
 
+               if (context->func && context->frame_interlace)
+                       gif_fill_in_lines (context, dest, v);
+               
                context->draw_xpos++;
                if (context->draw_xpos == context->frame_len) {
                        context->draw_xpos = 0;